<template>
  <div id="box">
    <el-row style="margin-top:20px ;">
      <el-col :span="21" style="margin-left:2% ;">
        <span>首次初步诊断：</span>
        <el-select v-model="diagnoseVal" size="small" disabled>
          <el-option v-for="item in diagnoseOptions" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-col>
      <el-col :span="2"><el-button type="primary" @click="saveEvent()">保存</el-button></el-col>
    </el-row>
    <el-row class="dataAreaStyle">
      <div v-if="hasData" style="background-color:rgba(249, 249, 249, 1);height: 70vh; text-align: center;line-height: 20vh;width: 98vw;margin: 0 auto;">
        <h1>请在诊断评估模块内补录初步诊断!</h1>
      </div>
      <div v-else>
        <!-- label-position="left"   label-width="100px"-->
        <el-form :inline="true" :model="eventFormData" class="demo-form-inline pd-10" label-width="120px">
          <el-col v-if=" ['Non-ACS_cardiogenic_chest_pain','othercardiogenic','stayCheck'].includes(diagnoseVal) " :span="24">
            <el-form-item label="处理措施">
              <el-radio-group v-model="eventFormData[771]" @change="(val)=>{handleChange(val,771)}">
                <!-- <el-radio-group v-model="eventFormData[771]" @change="handleChange(eventFormData[771])"> -->
                <el-radio v-for="(item, key, index) in eventOptions[771]" :key="'event771-' + index" :label="key">{{ item.detail }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col v-if="diagnoseVal == 'siemidia'" :span="24">
            <el-col :span="24">
              <el-form-item label="措施" required>
                <el-radio-group v-model="eventFormData[779]" @change="(val)=>{handleChange(val,779)}">
                  <el-radio v-for="(item, key, index) in eventOptions[779]" :key="'event779-' + index" :label="key">{{ item.detail }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col v-if="eventFormData[779]=='0' " :span="24">
              <el-form-item label="无再灌注措施" required>
                <el-checkbox-group v-model="eventFormData[767]" @change="(val)=>{handleChange(val,767)}">
                  <el-checkbox v-for="(item, key, index) in eventOptions[767]" :key="'event767-' + index" :label="key">{{ item.detail }}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col v-if="eventFormData[779]=='1' " :span="24">
              <el-col :span="8">
                <el-form-item label="启动导管室时间" required label-width="140px">
                  <el-date-picker
                    v-model="eventFormData[112]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,112)}"
                  />
                  <!-- readonly -->
                  <!-- @focus="getUserListWebFun()" -->
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="决定介入手术时间" required label-width="140px">
                  <el-date-picker
                    v-model="eventFormData[595]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,595)}"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="决定医师">
                  <el-input v-model="eventFormData[710]" @change="(val)=>{handleChange(val,710)}" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="开始知情同意时间" required label-width="140px">
                  <el-date-picker
                    v-model="eventFormData[576]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,576)}"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="签署知情同意时间" required label-width="140px">
                  <el-date-picker
                    v-model="eventFormData[593]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,593)}"
                  />
                </el-form-item>
              </el-col>
            </el-col><!-- STAMI_直接PCI _ End -->
            <!-- STAMI_溶栓 -->
            <el-col v-if="eventFormData[779]=='2' " :span="24">
              <el-col :span="8">
                <el-form-item label="溶栓措施">
                  <el-radio-group v-model="eventFormData[770]" @change="(val)=>{handleChange(val,770)}">
                    <el-radio v-for="(item, key, index) in eventOptions[770]" :key="'event770-' + index" :label="key" style="box-shadow: none;" @click.native.prevent="radioClickCancel(key,770)">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col v-if="eventFormData[770]=='1'" :span="8">
                <el-form-item label="决定介入手术时间" required label-width="140px">
                  <el-date-picker
                    v-model="eventFormData[595]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,595)}"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="溶栓筛查" required>
                  <el-radio-group v-model="eventFormData[101]" @change="(val)=>{handleChange(val,101)}">
                    <el-radio v-for="(item, key, index) in eventOptions[101]" :key="'event101-' + index" :label="key">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col v-if="eventFormData[101]=='2'" :span="24">
                <el-form-item label="存在禁忌症" required>
                  <el-radio-group v-model="eventFormData['101gelu']" @change="(val)=>{handleChange(val,'101gelu')}">
                    <el-radio v-for="(item, key, index) in eventOptions['101gelu']" :key="'event101gelu-' + index" :label="key">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col v-if="eventFormData[101]=='1'" :span="24">
                <el-col :span="6">
                  <el-form-item label="溶栓场所" required>
                    <el-select v-model="eventFormData[704]" placeholder="请选择溶栓场所" @change="(val)=>{handleChange(val,704)}">
                      <el-option
                        v-for="(item, key, index) in eventOptions[704]"
                        :key="'event704-' + index"
                        :label="item.detail"
                        :value="key"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="直达溶栓场所" required>
                    <el-radio-group v-model="eventFormData['705']" @change="(val)=>{handleChange(val,'705')}">
                      <el-radio v-for="(item, key, index) in eventOptions['705']" :key="'event705-' + index" :label="key">{{ item.detail }}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="开始谈话时间" required>
                    <el-date-picker
                      v-model="eventFormData[596]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,596)}"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="签署知情同意时间" required label-width="140px">
                    <el-date-picker
                      v-model="eventFormData[206]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,206)}"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="开始溶栓时间" required>
                    <el-date-picker
                      v-model="eventFormData[57]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,57)}"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-col :span="6">
                    <el-form-item label="溶栓药" required>
                      <el-select v-model="eventFormData.order.json.medicineName" placeholder="请选择溶栓药">
                        <el-option
                          v-for="(item,index) in medicineOptions"
                          :key="'medicine' + index"
                          :label="item"
                          :value="item"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="剂量" required>
                      <el-select v-model="eventFormData.order.json.dosage" placeholder="请选择剂量">
                        <el-option
                          v-for="(item,index) in dosageOptions"
                          :key="'medicine' + index"
                          :label="item"
                          :value="item"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="溶栓结束时间" required>
                    <el-date-picker
                      v-model="eventFormData[104]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,104)}"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="溶栓再通" required>
                    <el-radio-group v-model="eventFormData['498']" @change="(val)=>{handleChange(val,'498')}">
                      <el-radio v-for="(item, key, index) in eventOptions['498']" :key="'event498-' + index" :label="key">{{ item.detail }}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-col>            <!-- STAMI_溶栓 _End-->
            <!-- STAMI_择期介入-->
            <el-col v-if="eventFormData[779]=='3' " :span="24">
              <el-col :span="8">
                <el-form-item label="决定介入手术时间" required label-width="140px">
                  <el-date-picker
                    v-model="eventFormData[595]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,595)}"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="造影开始时间" required>
                  <el-date-picker
                    v-model="eventFormData[117]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,117)}"
                  />
                </el-form-item>
              </el-col>
            </el-col>    <!-- STAMI_择期介入 _End-->
            <!-- STAMI_ CABG -->
            <el-col v-if="eventFormData[779]=='4' " :span="24">
              <el-col :span="8">
                <el-form-item label="决定CABG" required>
                  <el-date-picker
                    v-model="eventFormData[768]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,768)}"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="开始CABG" required>
                  <el-date-picker
                    v-model="eventFormData[769]"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期时间"
                    @change="(val)=>{handleChange(val,769)}"
                  />
                </el-form-item>
              </el-col>
            </el-col>    <!-- STAMI_ CABG _End-->
            <!-- STAMI_ 转运PCI -->
            <el-col v-if="eventFormData[779]=='5' " :span="24">
              <el-col :span="24">
                <el-form-item label="转运PCI " required>
                  <el-radio-group v-model="eventFormData['778']" @change="(val)=>{handleChange(val,'778')}">
                    <el-radio v-for="(item, key, index) in eventOptions['778']" :key="'event778-' + index" :label="key">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>

            </el-col>    <!-- STAMI_ 转运PCI _End-->
          </el-col><!-- STAMI _ End -->
          <!-- NSTAMI  -->
          <el-col v-if=" ['nstemidia','uadia'].includes(diagnoseVal) " :span="24">
            <el-col :span="24">
              <el-form-item label="策略 " required>
                <el-radio-group v-model="eventFormData['772']" @change="(val)=>{handleChange(val,'772')}">
                  <el-radio v-for="(item, key, index) in eventOptions['772']" :key="'event772-' + index" :label="key">{{ item.detail }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col v-if="eventFormData['772']=='2' " :span="24">
              <el-col :span="24">
                <el-form-item label="侵入性策略 " required>
                  <el-radio-group v-model="eventFormData['773']" @change="(val)=>{handleChange(val,'773')}">
                    <el-radio v-for="(item, key, index) in eventOptions['773']" :key="'event773-' + index" :label="key">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <!-- v-if="eventFormData['773']=='1' " -->
              <el-col :span="24">
                <el-col :span="8" v-if="eventFormData['773']<2">
                  <el-form-item label="启动导管室时间" required label-width="140px">
                    <el-date-picker
                      v-model="eventFormData[112]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,112)}"
                    />
                    <!-- readonly -->
                    <!-- @focus="getUserListWebFun()" -->
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="eventFormData['773']<2">
                  <el-form-item label="决定介入手术时间" required label-width="140px">
                    <el-date-picker
                      v-model="eventFormData[595]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,595)}"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="eventFormData['773']<2">
                  <el-form-item label="决定医师" label-width="140px">
                    <el-input v-model="eventFormData[710]" @change="(val)=>{handleChange(val, 710)}" />
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="eventFormData['773']<2">
                  <el-form-item label="开始知情同意时间" required label-width="140px">
                    <el-date-picker
                      v-model="eventFormData[576]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,576)}"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="eventFormData['773']<2">
                  <el-form-item label="签署知情同意时间" required label-width="140px">
                    <el-date-picker
                      v-model="eventFormData[593]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,593)}"
                    />
                  </el-form-item>
                </el-col>
              </el-col><!-- 侵入性策略 - 2h紧急介入治疗_ End -->
              <el-col v-if="eventFormData['773']<3" :span="24">
                <el-col :span="8">
                  <el-form-item label="实际介入治疗时间" required label-width="140px">
                    <el-date-picker
                      v-model="eventFormData[774]"
                      type="datetime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间"
                      @change="(val)=>{handleChange(val,774)}"
                    />
                  </el-form-item>
                </el-col>
              </el-col><!-- 侵入性策略 - 24h紧急介入治疗_ End -->
            </el-col>
          </el-col><!-- NSTAMI _ End -->
          <!-- 主动脉夹层  -->
          <el-col v-if=" ['aorticdissection'].includes(diagnoseVal) " :span="24">
            <el-col :span="24">
              <el-form-item label="治疗策略">
                <el-radio-group v-model="eventFormData['775']" @change="(val)=>{handleChange(val,'775')}">
                  <el-radio v-for="(item, key, index) in eventOptions['775']" :key="'event775-' + index" :label="key">{{ item.detail }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-col> <!-- 主动脉夹层 _ End -->
          <!-- 肺动脉栓塞  -->
          <el-col v-if=" ['pulmonary'].includes(diagnoseVal) " :span="24">
            <el-col :span="24">
              <el-col :span="24">
                <el-form-item label="溶栓筛查" required>
                  <el-radio-group v-model="eventFormData[101]" @change="(val)=>{handleChange(val,101)}">
                    <el-radio v-for="(item, key, index) in eventOptions[101]" :key="'event101-' + index" :label="key">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col v-if="eventFormData[101]=='2'" :span="24">
                <el-form-item label="存在禁忌症" required>
                  <el-radio-group v-model="eventFormData['101gelu']" @change="(val)=>{handleChange(val,'101gelu')}">
                    <el-radio v-for="(item, key, index) in eventOptions['101gelu']" :key="'event101gelu-' + index" :label="key">{{ item.detail }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col v-if="eventFormData[101]=='1'" :span="24">
                <el-col :span="24">
                  <el-form-item label="溶栓治疗" required>
                    <el-radio-group v-model="eventFormData[776]" @change="(val)=>{handleChange(val,776)}">
                      <el-radio v-for="(item, key, index) in eventOptions[776]" :key="'event776-' + index" :label="key">{{ item.detail }}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-col>
          </el-col> <!-- 肺动脉栓塞 _ End -->
        </el-form>
      </div>
    </el-row>
    <el-dialog
      title="请选择导管室医生"
      :visible.sync="chooseDoctorVisible"
      width="30%"
    >
      <span v-for="(item,index) in doctorList" :key="index" class="doctorStyle">
        <el-radio v-if="item.loggedIn" v-model="chooseDoctor" :label="item.id" border class="doctorRadioStyle ">
          <span>
            <div class=" fl">{{ item.name }}</div>
            <div class=" fr">在线</div>
          </span>
        </el-radio>
        <div v-else class="copyRadio el-radio doctorRadioStyle  el-radio--medium is-bordered" @click="offLineTips(item.name)">
          <span>
            <span class=" ">{{ item.name }}</span>
            <span class="fr ">离线</span>
          </span>
        </div>
      </span>

      <span slot="footer" class="dialog-footer">
        <el-button @click="chooseDoctorVisible = false">取 消</el-button>
        <el-button type="primary" @click="clcsNoticeCrFun()">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import { findDiagnosesClcs, getEventTouchs, findchipsByInstance, saveCure, getUserListWeb, clcsNoticeCr } from '@/api/green-channel/treatmentMeasures'
import formatTime from '@/utils/format'

export default {
  name: 'TreatmentMeasures',
  components: { },
  props: {
    checkrowdata: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      chooseDoctorVisible: false,
      hasData: false, // 无数据
      diagnoseVal: '', // 诊断结果
      doctorList: [], // 导管室医生列表
      chooseDoctor: '',
      // 初步诊断 下拉
      diagnoseOptions: [
        {
          value: '',
          label: '无'
        }, {
          value: 'siemidia',
          label: 'STEMI'
        }, {
          value: 'nstemidia',
          label: 'NSTEMI'
        }, {
          value: 'uadia',
          label: 'UA'
        }, {
          value: 'aorticdissection',
          label: '主动脉夹层'
        }, {
          value: 'pulmonary',
          label: '肺动脉栓塞'
        }, {
          value: 'Non-ACS_cardiogenic_chest_pain',
          label: '非ACS心源性胸痛'
        }, {
          value: 'othercardiogenic',
          label: '其他心源性胸痛'
        }, {
          value: 'stayCheck',
          label: '待查'
        }],
      //  诊断对照表
      contrastMap: [
        {
          name: 'undetermined',
          value: 'stayCheck'
        }, {
          name: 'chest_pain_unknown',
          value: 'stayCheck'
        }, {
          name: 'chest_tightness_unknown',
          value: 'stayCheck'
        }, {
          name: 'siemidia',
          value: 'siemidia'
        }, {
          name: 'nstemidia',
          value: 'nstemidia'
        }, {
          name: 'uadia',
          value: 'uadia'
        }, {
          name: 'aorticdissection',
          value: 'aorticdissection'
        }, {
          name: 'pulmonary',
          value: 'pulmonary'
        }, {
          name: 'Non-ACS_cardiogenic_chest_pain',
          value: 'Non-ACS_cardiogenic_chest_pain'
        }, {
          name: 'othercardiogenic',
          value: 'othercardiogenic'
        }
      ],
      eventSelectData: {}, // 查询到的event数据
      cureData: {}, // 存储数据
      eventFormData: {
        '771': '', // 待查 - 处理措施
        '779': '0', //  stami-措施
        // stami-直接PCI
        '112': '', //  启动导管室时间
        '595': '', //  决定介入手术时间
        '576': '', //  开始知情同意时间
        '593': '', //  签署知情同意时间
        '710': '', // 介入时间
        //  stami-无再灌注措施
        '767': [], // 无再灌注措施原因
        //  stami-溶栓
        '770': '', //  溶栓措施
        '101': '3', //  溶栓筛查
        '101gelu': '', //  溶栓筛查-不合适-禁忌症
        '704': '', //  溶栓筛查-合适-溶栓场所
        '705': '', //  溶栓筛查-合适-直达溶栓场所
        '596': '', //  溶栓筛查-合适-开始谈话时间
        '206': '', //  溶栓筛查-合适-签署知情同意时间
        '57': '', //  溶栓筛查-合适-开始溶栓时间
        // '704': '' ,//  溶栓筛查-合适-溶栓场所
        // '705': '' //   溶栓筛查-合适-溶栓场所
        '104': '', //  溶栓筛查-合适-溶栓结束时间
        '498': '', //   溶栓筛查-合适-溶栓再通

        order: {
          id: null,
          instanceType: 'thrombolysisOrder',
          itemName: '溶栓手术',
          itemType: 'thrombolysisOrder',
          json: { complication: '', dosage: '', medicineName: '' }
        },
        //  stami-择期介入
        '117': '', //  造影开始时间
        // '595': '', //  决定介入手术时间  (  已存在  )
        //  stami-CABG
        '768': '', //  决定CABG
        '769': '', //  开始CABG
        //  stami-转运PCI
        '778': '', //  转运PCI

        //  NSTAMI
        '772': '', //  策略
        '773': '', //  侵入性策略
        // '112...': '', //  启动导管室时间  等  (  已存在  )
        '774': '', //  实际介入治疗时间

        // 主动脉夹层
        '775': '', //  治疗策略

        // 肺动脉栓塞
        '776': '', //  溶栓治疗
        // '101': '', //  溶栓筛查 (  已存在  )
        //  无用数据
        '9999': '' //  无用数据
      },
      selectEventList: ['771', '779', '770', '704', '705', '498', '778', '772', '773', '775', '776'], // 单选下拉组
      timeEventList: ['112', '595', '576', '593', '596', '206', '57', '104', '117', '768', '769', '774'], // 时间组
      inputEventList: ['710'], // 输入框组
      checkboxEventList: ['767'], // 多选组
      geluEventList: ['101'], // 特殊组
      geluMap: {
        '101': '2'
      },
      medicineOptions: ['第一代', '第二代', '第三代'],
      dosageOptions: ['全量', '半量'],
      eventOptions: {
        '771': {
          '1': {
            detail: '收治入院',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '急诊留观',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '门诊治疗',
            property2: '3',
            hit_time: ''
          },
          '4': {
            detail: '随访',
            property2: '4',
            hit_time: ''
          }
        },
        '779': {
          '0': {
            detail: '无再灌注措施',
            property2: '0',
            hit_time: ''
          },
          '1': {
            detail: '直接PCI',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '溶栓',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '择期介入',
            property2: '3',
            hit_time: ''
          },
          '4': {
            detail: 'CABG',
            property2: '4',
            hit_time: ''
          },
          '5': {
            detail: '转运PCI',
            property2: '5',
            hit_time: ''
          }
        },
        '767': {
          '1': {
            detail: '生命体征平稳，无持续缺血表现',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '超过再灌注时间窗',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '高出血风险',
            property2: '3',
            hit_time: ''
          },
          '4': {
            detail: '严重肝肾功能不全',
            property2: '4',
            hit_time: ''
          },
          '5': {
            detail: '经济原因限制',
            property2: '5',
            hit_time: ''
          },
          '6': {
            detail: '拒绝或放弃',
            property2: '6',
            hit_time: ''
          },
          '7': {
            detail: '出血活动期',
            property2: '7',
            hit_time: ''
          },
          '9': {
            detail: '其他原因',
            property2: '9',
            hit_time: ''
          }
        },
        '770': {
          '1': {
            detail: '补救PCI',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '溶栓后介入',
            property2: '2',
            hit_time: ''
          }
        },
        '101': {
          '1': {
            detail: '合适',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '不合适',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '未筛查',
            property2: '3',
            hit_time: ''
          }
        },
        '101gelu': {
          '1': {
            detail: '是',
            property2: '1',
            hit_time: ''
          },
          '0': {
            detail: '否',
            property2: '0',
            hit_time: ''
          }
        },
        '704': {
          '1': {
            detail: '本院急诊科',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '本院心内科',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '其他科室',
            property2: '3',
            hit_time: ''
          }
        },
        '705': {
          '1': {
            detail: '是',
            property2: '1',
            hit_time: ''
          },
          '0': {
            detail: '否',
            property2: '0',
            hit_time: ''
          }
        },
        '498': {
          '1': {
            detail: '是',
            property2: '1',
            hit_time: ''
          },
          '0': {
            detail: '否',
            property2: '0',
            hit_time: ''
          }
        },
        '778': {
          '1': {
            detail: '转出患者',
            property2: '1',
            hit_time: ''
          },
          '0': {
            detail: '接收患者',
            property2: '0',
            hit_time: ''
          }
        },
        '772': {
          '1': {
            detail: '保守治疗(仅药物治疗)',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '侵入性策略',
            property2: '2',
            hit_time: ''
          }
        },
        '773': {
          '1': {
            detail: '2h紧急介入治疗',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '24h内介入治疗',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '72h内介入治疗',
            property2: '3',
            hit_time: ''
          },
          '4': {
            detail: '择期介入治疗',
            property2: '4',
            hit_time: ''
          },
          '5': {
            detail: 'CABG',
            property2: '5',
            hit_time: ''
          }
        },
        '775': {
          '1': {
            detail: '紧急介入治疗',
            property2: '1',
            hit_time: ''
          },
          '2': {
            detail: '择期介入治疗',
            property2: '2',
            hit_time: ''
          },
          '3': {
            detail: '保守治疗',
            property2: '3',
            hit_time: ''
          },
          '4': {
            detail: '外科手术',
            property2: '4',
            hit_time: ''
          },
          '5': {
            detail: '其他（介入失败转手术）',
            property2: '5',
            hit_time: ''
          }
        },
        '776': {
          '1': {
            detail: '有',
            property2: '1',
            hit_time: ''
          },
          '0': {
            detail: '无',
            property2: '0',
            hit_time: ''
          }
        }
      }
    }
  },
  created() {
  },
  mounted() {
    this.findDiagnosesClcsFun()
    this.getEventTouchsFun()
    this.findchipsByInstanceFun()
    // this.getUserListWebFun()
  },
  methods: {
    // 使用原生点击事件实现单选按钮取消功能
    radioClickCancel(key, name) {
      if (this.eventFormData[name] === key) {
        this.eventFormData[name] = null
        this.handleChange('', name)
      } else {
        this.eventFormData[name] = key
        this.handleChange(key, name)
      }
      // console.log(1, key, name)
    },
    // 发送导管室请求
    clcsNoticeCrFun(name) {
      if (!this.chooseDoctor) {
        this.$message.warning(`至少选择一名医生`)
        return
      }
      const params = {
        dispatchId: this.checkrowdata.dispatchId,
        apiToken: this.$store.getters.apiToken,
        touserId: this.chooseDoctor
      }
      clcsNoticeCr(params).then(res => {
        if (res.code === 0) {
          // this.$set(this.eventFormData, '112', res.dateTime)

          this.handleChange(res.data['112'], '112')
          this.handleChange(res.data['595'], '595')
          this.handleChange(res.data['710'], '710')
          this.eventFormData['112'] = res.data['112']
          this.eventFormData['595'] = res.data['595']
          this.eventFormData['710'] = res.data['710']
          // console.log(this.eventFormData[112])
          this.$message.success('发送成功')
          this.chooseDoctor = ''
          this.chooseDoctorVisible = false
        } else {
          this.$message.error('请求异常')
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 离线医生提示
    offLineTips(name) {
      this.$message.info(`请拨打 ${name} 医生的手机号`)
    },
    // 获取导管室医生列表
    getUserListWebFun() {
      const params = {
        departmentNameStr: '导管室',
        dispatchId: this.checkrowdata.dispatchId
      }
      getUserListWeb(params).then(res => {
        if (res.code === 0) {
          this.doctorList = res.data
          this.chooseDoctorVisible = true
        } else {
          this.$message.warning('获取导管室医生列表异常')
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 获取 stami-溶栓-溶栓药和剂量
    findchipsByInstanceFun() {
      const dispatch = this.checkrowdata.dispatchId
      let model = {
        id: null,
        instanceType: 'thrombolysisOrder',
        itemName: '溶栓手术',
        itemType: 'thrombolysisOrder',
        json: { complication: '', dosage: '', medicineName: '' },
        medicalId: this.checkrowdata.medicalId,
        missionid: dispatch,
        status: true,
        userId: this.$store.getters.userId
      }
      findchipsByInstance(dispatch).then(res => {
        if (res.data.chipsOrder.length) {
          model = res.data.chipsOrder[0]
        }
        // console.log("model.json",model.json)
        model.json = JSON.parse(JSON.stringify(model.json))
        this.eventFormData.order = model
      }).catch(err => {
        console.log(err)
      })
      // this.$set( this.eventFormData, "order",model)
      // console.log(model)
      // console.log(9999,this.eventFormData.order)
      // this.eventFormData.order = model
    },
    // 查询Event事件
    getEventTouchsFun() {
      const dispatch = this.checkrowdata.dispatchId
      getEventTouchs(dispatch).then(res => {
        this.eventSelectData = res.data
        Object.keys(this.eventFormData).forEach(itemLabel => {
          const data = res.data[itemLabel]
          if (data) {
            // 时间
            if (this.timeEventList.includes(itemLabel)) {
              this.eventFormData[itemLabel] = data.hit_time
            }
            // 输入框
            if (this.inputEventList.includes(itemLabel)) {
              this.eventFormData[itemLabel] = data.detail
            }
            // 单选下拉
            if (this.selectEventList.includes(itemLabel)) {
              this.eventFormData[itemLabel] = data.property2
            }
            // 多选组
            if (this.checkboxEventList.includes(itemLabel)) {
              this.eventFormData[itemLabel] = this.strToArr(data.property2)
            }
            if (this.geluEventList.includes(itemLabel)) { // 存在禁忌症
              if (data.property2 && data.property2.indexOf('~') > -1) {
                const geluArr = data.property2.split('~')
                this.eventFormData[itemLabel] = geluArr[0]
                this.eventFormData[itemLabel + 'gelu'] = geluArr[1]
              } else {
                this.eventFormData[itemLabel] = data.property2
              }
            }
          }
        })
      }).catch(err => {
        console.log(err)
      })
    },
    strToArr(str, separator = '|') {
      if (str) {
        return str.split(separator)
      }
      return []
    },
    arrToStr(arr, separator = '|') {
      if (arr.length > 0) {
        return arr.join(separator)
      }
      return ''
    },
    handleChange(val, eventId) {
      // console.log(2, val, eventId)
      const selectData = this.eventSelectData[eventId]
      const temp = {
        detail: '',
        property2: '',
        hit_time: '',
        id: selectData ? selectData.id : null,
        eventId: eventId,
        missionid: this.checkrowdata.dispatchId,
        user: this.$store.getters.userId
      }
      eventId = eventId.toString()
      // 时间
      if (this.timeEventList.includes(eventId)) {
        temp.hit_time = val
      }
      // 输入框
      if (this.inputEventList.includes(eventId)) {
        temp.detail = val
      }
      // 单选下拉
      if (this.selectEventList.includes(eventId)) {
        const optionsData = this.eventOptions[eventId][val] || temp
        if (!val) {
          // 为可取消单选(770)赋值hitTime,避免后台报错
          temp.hit_time = formatTime(new Date(), 'YYYY-MM-DD HH:mm:ss')
        }
        temp.detail = optionsData.detail
        temp.property2 = optionsData.property2
      }
      // 多选组
      if (this.checkboxEventList.includes(eventId)) {
        const arr = val
        const dl = []; const p2 = []
        arr.forEach(item => {
          dl.push(this.eventOptions[eventId][item].detail)
          p2.push(this.eventOptions[eventId][item].property2)
        })
        temp.detail = this.arrToStr(dl, ';')
        temp.property2 = this.arrToStr(p2, '|')
      }
      // 特殊父组
      if (this.geluEventList.includes(eventId)) {
        const optionsData = this.eventOptions[eventId][val]
        const childEventId = eventId + 'gelu'
        const cP2_index = this.eventFormData[childEventId] // 子项的值,对应Options中下标
        const cOptions = this.eventOptions[childEventId] // 子项的options
        // 先将父项值取出
        temp.detail = optionsData.detail
        temp.property2 = optionsData.property2
        // 若父项为指定项且子项有值, 则进行 ~拼接
        if (this.geluMap[eventId] === val && cP2_index !== '') {
          temp.detail = cOptions[cP2_index].detail
          temp.property2 = temp.property2 + '~' + cOptions[cP2_index].property2
        }
      }
      // 特殊子组
      if (eventId.indexOf('gelu') > -1) {
        const optionsData = this.eventOptions[eventId][val]
        const farEventId = parseInt(eventId).toString()
        temp.id = temp.id ? temp.id : this.eventSelectData[farEventId].id
        temp.detail = optionsData.detail
        if (this.cureData[farEventId]) {
          if (this.cureData[farEventId].property2.indexOf('~') > -1) {
            temp.property2 = this.cureData[farEventId].property2.split('~')[0] + '~' + optionsData.property2
          } else {
            temp.property2 = this.cureData[farEventId].property2 + '~' + optionsData.property2
          }
        } else {
          temp.property2 = this.geluMap[farEventId] + '~' + val
        }
        eventId = farEventId
        temp.eventId = farEventId
      }

      this.cureData[eventId] = { ...temp }
    },
    saveEvent() {
      const cureArr = []
      Object.values(this.cureData).forEach(item => {
        cureArr.push(JSON.stringify(item))
      })
      const data = {
        cure: cureArr.join('#') || undefined,
        order: this.eventFormData.order
      }
      saveCure(data).then(res => {
        if (res.code === 0) {
          this.$message.success('保存成功')
          this.cureData = {} // 清空存值数据
          this.findDiagnosesClcsFun()
          this.getEventTouchsFun()
          this.findchipsByInstanceFun()
        } else {
          this.$message.error('保存失败')
        }
      }).catch(err => {
        this.$message.error('保存失败')
        console.log(err)
      })
    },

    // 查询诊断
    findDiagnosesClcsFun() {
      findDiagnosesClcs({
        dispatchId: this.checkrowdata.dispatchId
      }).then((res) => {
        if (res.length === 0) {
          this.hasData = true
        } else {
          const diagnoseArr = JSON.parse({ ...res[0] }.diagnoseContent)
          this.contrastMap.forEach(item => {
            if (diagnoseArr.includes(item.name)) {
              this.diagnoseVal = item.value
            }
          })
          // 若未获取到任何诊断
          if (!this.diagnoseVal) {
            this.hasData = true
          }
        }
      })
    }

  }
}
</script>

<style scoped="scoped">
.form >>> .el-form-item__label {
  font-size: 16px;
  font-weight: 400;
  color: #000000;
}
.dataAreaStyle {
  background-color: rgba(249, 249, 249, 1);
  margin: 20px;
  min-height: 70vh;
}
.el-form-item {
    line-height: 38px;
}
.doctorStyle {
  width: 100%;
}
.doctorStyle >>> .el-radio__input{
  display: none
}
.doctorStyle >>> .doctorRadioStyle{
  width:48%;
  margin: 5px 1%!important;
}
#box >>> .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
    -webkit-box-shadow: none;
    box-shadow: none
}
/* {
  outline: none;
} */
</style>
